﻿<!--
<summary>
    // This dialog will allow the user to perform discarding functions
    // to a sequence file. The user can select between discarding by 
    // length or by quality score. The output is will be written to
    // a new file specified by the user.
</summary>
-->
<src:ToolBaseDialog x:Class="SeqcosGui.Dialog.DiscardDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:src="clr-namespace:SeqcosGui.Dialog"
        xmlns:valid="clr-namespace:SeqcosGui.ValidationRules"
        xmlns:local="clr-namespace:SeqcosFilterTools.Discard;assembly=SeqcosFilterTools"
        Title="{DynamicResource DiscardDialog_Title}" 
        ResizeMode="NoResize"
        WindowStartupLocation="CenterOwner"
        BorderBrush="Black" BorderThickness="1" 
        MaxHeight="500" Width="464" Background="Gainsboro" SizeToContent="Height" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="440">
    <Window.Resources>
        <Style x:Key="ParamaterTextField" TargetType="{x:Type TextBlock}">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="TextAlignment" Value="Left" />
        </Style>
        <Style x:Key="Note" TargetType="{x:Type TextBlock}">
            <Setter Property="Margin" Value="0,0,0,5" />
            <Setter Property="FontSize" Value="10" />
        </Style>
        <local:DiscardByLength x:Key="myDiscardByLength" />
        <local:DiscardByMeanQuality x:Key="myDiscardByMeanQuality" />
        <local:DiscardByRegex x:Key="myDiscardByRegex" />
        <Style x:Key="valueInError" TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip"
                            Value="{Binding RelativeSource={x:Static RelativeSource.Self},
                            Path=(Validation.Errors)[0].ErrorContent}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <DockPanel>

        <!-- Trim Options -->
        <TabControl DockPanel.Dock="Top">
            <!-- By Length -->
            <TabItem Header="{DynamicResource Length_Title}" Name="tabByLength">
                <StackPanel>
                    <TextBlock Text="{DynamicResource Generic_Required}" Style="{StaticResource Note}" />
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="2*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" TextAlignment="Left" Text="{DynamicResource DiscardDialog_Length_Select}" VerticalAlignment="Center" ToolTip="{StaticResource DiscardDialog_Length_SelectTip}" Style="{StaticResource ParamaterTextField}" />
                        <TextBox Grid.Column="1" Name="discardLengthValue" Width="100"
                            Style="{StaticResource valueInError}">
                            <TextBox.Text>
                                <Binding Path="MinLengthThreshold" Source="{StaticResource myDiscardByLength}" UpdateSourceTrigger="PropertyChanged">
                                    <Binding.ValidationRules>
                                        <valid:PositiveIntegerValidationRule ValidatesOnTargetUpdated="True"/>
                                    </Binding.ValidationRules>
                                </Binding>
                            </TextBox.Text>
                        </TextBox>
                    </Grid>

                </StackPanel>
            </TabItem>
            
            <!-- By Quality Score -->
            <TabItem Header="{DynamicResource Quality_Title}" Name="tabByQuality">
                <StackPanel>
                    <TextBlock Text="{DynamicResource Generic_Required}" Style="{StaticResource Note}" />

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="4*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" Text="{DynamicResource DiscardDialog_Quality_Select}" TextWrapping="Wrap" ToolTip="{StaticResource DiscardDialog_Quality_SelectTip}" TextAlignment="Left" />
                        <TextBox Grid.Column="1" Name="discardQualityValue" Width="50" Height="25"
                            Style="{StaticResource valueInError}">
                            <TextBox.Text>
                                <Binding Path="MeanQualityThreshold" Source="{StaticResource myDiscardByMeanQuality}" UpdateSourceTrigger="PropertyChanged">
                                    <Binding.ValidationRules>
                                        <valid:PositiveIntegerValidationRule ValidatesOnTargetUpdated="True"/>
                                    </Binding.ValidationRules>
                                </Binding>
                            </TextBox.Text>
                        </TextBox>
                    </Grid>

                </StackPanel>
            </TabItem>
            
            <!-- By Regex -->
            <TabItem Header="{DynamicResource Regex_Title}" Name="tabByRegex">
                <StackPanel>
                    <TextBlock Text="{DynamicResource Generic_Required}" Style="{StaticResource Note}" />

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" Text="{DynamicResource Regex_Select}" TextWrapping="Wrap" Style="{StaticResource ParamaterTextField}" />
                        <TextBox Grid.Column="1" Name="discardRegexPattern" Width="155" Height="25" 
                            Style="{StaticResource valueInError}">
                            <TextBox.Text>
                                <Binding Path="Pattern" Source="{StaticResource myDiscardByRegex}" UpdateSourceTrigger="LostFocus">
                                    <Binding.ValidationRules>
                                        <valid:RegexValidationRule ValidatesOnTargetUpdated="True"/>
                                    </Binding.ValidationRules>
                                </Binding>
                            </TextBox.Text>

                        </TextBox>

                    </Grid>
                </StackPanel>

            </TabItem>
        </TabControl>

        <!-- Input/Output files -->
        <StackPanel DockPanel.Dock="Top">
            <src:IoUserControl x:Name="ioControl" />
        </StackPanel>

        <!-- Finalize buttons -->
        <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Height="30">
            <Button Name="btnRun" Content="{StaticResource Generic_Run}" MaxHeight="25" Click="OnRunClicked" Width="50" IsDefault="True" IsEnabled="False" />
            <Button Name="btnCancel" Content="{StaticResource Generic_Cancel}" Margin="4,0,0,0" MaxHeight="25" Click="OnCancelClicked" IsCancel="True" />
        </StackPanel>

    </DockPanel>
</src:ToolBaseDialog>
